{% extends 'base.html' %}

{% block title %}详情{% endblock %}
{% block head %}
    <link rel="stylesheet" href="{{ url_for('static',filename='css/detail.css') }}">
{% endblock %}

{% block main %}
    <div class="question-detail">
        <h3 class="page-title">{{ question.title }}</h3>
        <p class="question-info">
            <span class="question-author">作者：{{ question.author.username | default('匿名', true) }}</span>
            <span class="question-time">时间：{{ question.create_time }}</span>
        </p>
        <hr>
        <div class="question-content">
            {{ question.content }}
        </div>
        <hr>
        <div class="answer">
            <h4>评论:（{{ question.answers | count }}）</h4>
            <form action="{{ url_for('add_answer',question_id=question.id) }}" method="post">
                <div class="form-group">
                    <input type="text" class="form-control" name="answer_content" placeholder="请填写评论">
                    <input type="hidden" name="question_id" value="{{ question.id }}">
                </div>
                <div class="form-group" style="text-align: right">
                    <button type="submit" class="btn btn-primary">立即评论</button>
                </div>
            </form>
        </div>
        <hr>
        <div>
            <ul class="answer-list">
                {% for answer in question.answers %}
                <li>
                    <div class="user-info">
                        <img src="{{ url_for('static', filename='images/logo2.png') }}" alt="作者头像" class="avatar">
                        <span class="username">{{ answer.author.username | default('匿名', true) }}</span>
                        <span class="create-time">{{ answer.create_time }}</span>
                    </div>
                    <p class="answer-content">{{ answer.content }}</p>
                </li>
            {% endfor %}
            </ul>
        </div>
    </div>
{% endblock %}